import request from "@/utils/request";
enum Api {
  courseListAuth = "/course/getCourseList",
  courseAllExercise = "/course/getCourcePaperDetails/",
  courseExercise = "/course/getCourceChapterDetails/",
  saveCourseExercise = "/exercise/saveCourseExercise",
  errCourseExercise = "/exercise/wrongQuestionList/",
  courseWrongExercise = "/course/getWrongCourcePaperDetails/",
  statistics = "/exercise/answerStatistics",
  exerciseHistory = "/exercise/getExerciseHistory/",
  getDict = "/system/dict/data/type/",
}

// 获取课程鉴权列表
export function getCourseListAuth(query: Object) {
  return request({
    url: Api.courseListAuth,
    method: "get",
    params: query,
  });
}

// 获取课程练习习题
export function getCourseAllExercise(id: string) {
  return request({ url: Api.courseAllExercise + id, method: "get" });
}

// 获取课程 - 章节 - 练习习题
export function getCourseExercise(id: string) {
  return request({ url: Api.courseExercise + id, method: "get" });
}

// 保存课程练习习题
export function saveCourseExercise(data) {
  return request({ url: Api.saveCourseExercise, method: "post", data });
}

// 错题本
export function errCourseExercise(id: string) {
  return request({ url: Api.errCourseExercise + id, method: "get" });
}

// 获取课程错题本练习习题
export function getCourseWrongExercise(id: string, query) {
  return request({
    url: Api.courseWrongExercise + id,
    method: "get",
    params: query,
  });
}

// 答题统计
export function statistics() {
  return request({ url: Api.statistics, method: "get" });
}

// 联系历史
export function exerciseHistory(id: string) {
  return request({ url: Api.exerciseHistory + id, method: "get" });
}

// 路由词典
export function getDictOption(name) {
  return request({ url: Api.getDict + name, method: "get" });
}
